package com.shilei.iterator.v2;

/**
 * @description: 构建一个容器 ，可以添加对象  链表
 * @author: 81271
 * @date: 2020-04-19 19:52
 */
public class Main {
    public static void main(String[] args) {
        LinkedList_ linkedList_ = new LinkedList_();
        for (int i = 0; i < 15; i++) {
            linkedList_.add("i" + i);
        }
        System.out.println(linkedList_.size());
    }
}

class LinkedList_ {
    Node head = null;
    Node tail = null;

    private int size = 0;


    public void add(Object o) {
        Node node = new Node(o);
        node.next = null;

        if (head == null) {
            head = node;
            tail = node;
        }
        tail.next = node;
        tail = node;

        size ++;
    }

    private class Node {
        private Object o;
        Node next;

        public Node(Object o) {
            this.o = o;
        }
    }

    public int size() {
        return size;
    }
}

